﻿@{
    ViewBag.Title = "编制剪切下料卡优选方案";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<link href="~/Content/css/common.css" rel="stylesheet" />
<link href="~/Content/css/BlankingcardAdd.css" rel="stylesheet" />
<style type="text/css">
    .tool_c {
        padding: 10px 0;
    }

    .btn-group {
        padding: 0 10px 0 0;
    }

</style>
<script>
    $(function () {
        Index.init();
    });

    var Index = {
        id: null,
        dataList:null,
        imgTemplate:null,
        init: function () {
            $("img").error(function () {
                $(this).hide(0);
            });
            with (Index) {
                id = $.request("FProductionNO");

                Index.imgTemplate = $(".draw_area").html();

                loadData();

                initControl();

               
            }
        },
        initControl: function () {
            $("#butnBack").on("click", function () {
                $.goBack();
            });

            $("#butnConfirm").on("click", function () {
                var id = $("#gridList1").jqGrid('getGridParam', 'selrow');

                !!id || $.modalAlert("请选择需要设置的排样方案。", "error");

                !!id && (function () {
                    var MatListID = Index.dataList.rows[id - 1]["MatListID"];
                    console.log(MatListID);
                    $.post("/BOM/Blankingcard/ConfirmLayoutSets", { MatListID: MatListID }, function (res) {
                        0 < res || $.modalAlert("设置排样方案失败,请联系管理员", "error");

                        0 < res && $("#btn_search1").trigger("click");
                    });
                })();
            });
        },
        loadData: function () {
            var conn1 = {
                "FProductionNO": Index.id
            };
            var $gridList1 = $("#gridList1");///BOM/Blankingcard/GetBlankingcards
            $gridList1.dataGridForJson({
                url: "/BOM/Blankingcard/GetBlankingcardLayoutSets",
                postData: conn1,
                height: 80,
                colModel: [
                { label: '编号', name: 'MatListID', width: 120, align: 'left', sortable: false, frozen: true,hidden:true },
                { label: '下料卡号', name: 'MatNO', width: 120, align: 'left', sortable: false, frozen: true },
                { label: '单位', name: 'ProductUnit_Name', width: 160, align: 'left', sortable: false, frozen: true },
                { label: '车间', name: 'ProduWorkshop_Name', width: 160, align: 'left', sortable: false, frozen: true },
                { label: '钢板<br/>张数', name: 'FQuantity_GB', width: 40, align: 'right', sortable: false, frozen: true },
                { label: '毛坯<br/>符号', name: 'Sign_MP', width: 80, align: 'right', sortable: false, frozen: true },
                { label: '零件编号', name: 'FProductionNOName', width: 120, align: 'left', sortable: false, frozen: true },
                { label: '零件编号（隐藏）', name: '"	FProductionNO', width: 120, align: 'left', sortable: false,hidden:true },
                { label: '零件名称（隐藏）', name: 'FProductionName', width: 160, align: 'left', sortable: false, hidden: true },
                { label: '投料重量<br/>(kg)', name: 'FQuantity_GBZL', width: 80, align: 'left', sortable: false },
                { label: '材料要求', name: 'MaterialCode_YCL', width: 40, align: 'left', sortable: false },
                { label: '材料规格(mm)', name: 'MaterialSizes_BL', width: 60, align: 'right', sortable: false },
                { label: '实际材料', name: 'MaterialCode_SJBL', width: 80, align: 'right', sortable: false },
                { label: '材料规格(mm)', name: 'MaterialSizes_SJBL', width: 80, align: 'right', sortable: false },
                { label: '开卷尺寸(mm)', name: 'MaterialSizes_K1', width: 180, align: 'left', sortable: false },
                { label: '剪切规格(mm)', name: 'MaterialSizes_J', width: 80, align: 'right', sortable: false },
                { label: '可制件数', name: 'KZLJ', width: 180, align: 'left', sortable: false },
                { label: '利用率(%)', name: 'LYL_TL', width: 80, align: 'right', sortable: false },
                { label: '方向', name: 'FiberDirection', width: 180, align: 'left', sortable: false },
                { label: '毛坯类型', name: 'RoughsType', width: 80, align: 'right', sortable: false },
                { label: '毛坯尺寸(mm)', name: 'RoughsSize', width: 70, align: 'left', sortable: false },
                { label: '零件净重(kg)', name: 'PartsNetWeight', width: 70, align: 'center', sortable: false },
                { label: '材料定额(kg)', name: 'MaterialQuota_TL', width: 70, align: 'center', sortable: false },
                { label: '一级废料规格', name: 'FLGG1', width: 80, align: 'left', sortable: false },
                { label: '一级废料重量', name: 'FLZL1', width: 70, align: 'center', sortable: false },
                { label: '二级废料规格', name: 'FLGG2', width: 80, align: 'left', sortable: false },
                { label: '二级废料重量', name: 'FLZL2', width: 70, align: 'center', sortable: false },
                { label: '三级废料规格', name: 'FLGG3', width: 80, align: 'left', sortable: false },
                { label: '三级废料重量', name: 'FLZL3', width: 70, align: 'center', sortable: false },
                { label: '余料规格1(mm)', name: 'YLGG1', width: 80, align: 'left', sortable: false },
                { label: '余料数量1', name: 'YLSL1', width: 70, align: 'center', sortable: false },
                { label: '余料规格2（mm)', name: 'YLGG2', width: 80, align: 'left', sortable: false },
                { label: '余料数量2', name: 'YLSL2', width: 70, align: 'center', sortable: false },
                { label: '余料规格3（mm)', name: 'YLGG3', width: 80, align: 'left', sortable: false },
                { label: '余料数量3', name: 'YLSL3', width: 70, align: 'center', sortable: false },
                { label: '输入人员', name: 'InputUser', width: 70, align: 'center', sortable: false },
                { label: '输入日期', name: 'InputDate', width: 80, align: 'left', sortable: false },
                { label: '输入时间', name: 'InputTime', width: 70, align: 'center', sortable: false },
                { label: '审核人员', name: 'FAuditingBy', width: 80, align: 'left', sortable: false },
                { label: '审核日期', name: 'FAuditingDate', width: 70, align: 'center', sortable: false },
                { label: '审核时间', name: 'FAuditingTime', width: 80, align: 'left', sortable: false },
                { label: 'BFFX', name: 'BFFX', width: 70, align: 'center', sortable: false }
                ],
                pager: "#gridPager1",
                sortname: ' InputDate,InputTime,MatNO ',
                sortorder: "desc,desc,asc",
                viewrecords: true,
                rownumWidth: 50,
                onSelectRow: function (rowId) {
                    
                    rowData = $gridList1.jqGrid('getRowData', rowId);
                    
                    var url = "/BOM/Blankingcard/GetPreferredPicture?id={0}".format(rowData["MatListID"]);

                    $(".draw_area").html(Index.imgTemplate.format({ picPath:url}));

                },
                loadComplete: function (data) {
                    Index.dataList = data;
                }
            });
            $gridList1.jqGrid('setFrozenColumns');
            $gridList1.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
        }
    };



</script>
<div class="layout" id="layout" style="height: 100%; width: 100%;">
    <h1>编制剪切下料卡优选方案</h1>

    <div class="table_c">
        <table id="gridList1" class="frozen_fixed"></table>
        <div id="gridPager1"></div>
    </div>
    <div class="draw_area">
            <img src="{picPath}" alt="card" title="card" />
    </div>
    <footer>
        <div class="btn-group">
            <a id="butnConfirm" class="btn btn-primary center-block i1 i12"><span class="glyphicon glyphicon-ok"></span>确定</a>
            <a id="butnBack" class="btn btn-primary center-block i1 i12"><span class="glyphicon glyphicon-arrow-left"></span>返回</a>
        </div>
    </footer>
</div>



